// 写这个 Hook 是因为他妈逼的这个傻逼路由库挂一个路由守卫就崩掉了，傻逼！

import { useUserInfoStore } from '@/store/userInfo'

export function useRouterGuards() {
  const router = useRouter()
  const userInfoStore = useUserInfoStore()

  const routerGuards = (success: () => void) => {
    if (userInfoStore.userInfo?.token)
      success()
    else
      router.push('login')
  }

  return routerGuards
}
